<!doctype html>
<html lang="en">	
	<head>
		<meta charset="UTF-8">
		<meta name="Generator" content="EditPlus®">
		<meta name="Author" content="">
		<meta name="Keywords" content="">
		<meta name="Description" content="">
		<title>Document</title>
		<style>
			*{margin:0;padding:0;}
			a{text-decoration:none;}
			ul,li{list-style:none;}
			body{font-size:12px;font-family:"微软雅黑";}
			/*通过自定义属性选择元素*/
			.c_box[data-of-sex]{
				width:100px;
				height:100px;
				background:red;
				margin:100px auto;
			}
			

		</style>
	</head>
	<body>
		
		<div id="box" class="c_box" title="盒子" name="马超" data-of-sex="男">div</div>
		<script type="text/javascript">
			//1.通过id获取元素
			var dom = document.getElementById("box");
			//判决是否有自定义属性
			console.log(dom.hasAttribute("title"));
			//获取自定义属性
			console.log(dom.getAttribute("title"));
			//设置自定义属性 可设置新的属性  可修改属性
			dom.setAttribute("age","18");
			dom.setAttribute("name","赵云");
			console.log(dom.getAttribute("age"));
			console.log(dom.getAttribute("name"));
			//删除属性
			console.log(dom.removeAttribute("sex"));
			//修改自定义属性值
			console.log(dom.dataset.ofSex="女");

			//定义字符串 ws6

			var str = `
			   床前明月光,
			   意识地上霜,
			   举头望明月,
			   低头思故乡.`;
			console.log(str);
		</script>	
		
		
	</body>
</html>
